unit KasaGirisi;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FormClass, XPMan, StdActns, ActnList, StdCtrls, Buttons,
  ExtCtrls, cxControls, cxContainer, cxEdit, cxGroupBox, wwdblook, Mask,
  wwdbedit, Wwdotdot, wwdbdatetimepicker, DB, ADODB;

type
  TfmKasaGirisi = class(TfmFormClass)
    pnlButton: TPanel;
    bkaydet: TBitBtn;
    bvazgec: TBitBtn;
    bkapat: TBitBtn;
    bekle: TPanel;
    acKaydet: TAction;
    acVazgec: TAction;
    cxGroupBox1: TcxGroupBox;
    Label1: TLabel;
    Tarih: TwwDBDateTimePicker;
    Label2: TLabel;
    edtCarKod: TwwDBComboDlg;
    Label3: TLabel;
    edtCarAd: TwwDBComboDlg;
    adoListe: TADOQuery;
    dsListe: TDataSource;
    aqKasa: TADOQuery;
    dsKasa: TDataSource;
    Label4: TLabel;
    Label5: TLabel;
    edtGiren: TwwDBEdit;
    edtCikan: TwwDBEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    KasaharID: Integer;
    procedure ShowRecord(ID: Integer);
  public
    { Public declarations }
    procedure GetKasahar(ID: Integer; OpenType: string);
  end;

var
  fmKasaGirisi: TfmKasaGirisi;

implementation

{$R *.dfm}

procedure TfmKasaGirisi.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmKasaGirisi := nil;
end;

procedure TfmKasaGirisi.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Key = 27 then
    Exit;
end;

procedure TfmKasaGirisi.FormCreate(Sender: TObject);
begin
  inherited;
  KasaharID := 0;
end;

procedure TfmKasaGirisi.GetKasahar(ID: Integer; OpenType: string);
begin
  KasaharID := ID;
  ShowRecord(KasaharID);
  if OpenType = 'Y' then
  begin
    aqKasa.Insert;
  end
  else
    if OpenType = 'D' then
    begin
      aqKasa.Edit;
    end
    else
      if OpenType = 'I' then
      begin

      end;
end;

procedure TfmKasaGirisi.ShowRecord(ID: Integer);
begin
  with adoListe do
  begin
    Close;
    Parameters.ParamByName('RefID').Value := ID;
    Open;

//    if RecordCount > 0 then
//    begin
    edtCarKod.Text := FieldByName('CariKodu').AsString;
    edtCarAd.Text := FieldByName('FirmaAdi').AsString;
//    end;

  end;

  with aqKasa do
  begin
    Close;
    Parameters.ParamByName('RefID').Value := ID;
    Open;
  end;
end;

end.

